package com.chushouya.order.dto.admin.paymentlog;

import com.chushouya.order.constants.PaymentStatusEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * 支付结果DTO
 */
@ApiModel("支付结果信息")
@Data
public class PaymentResultDTO {

    @ApiModelProperty("支付状态：0=处理中，1=支付成功，2=支付失败")
    private Integer status;

    @ApiModelProperty("支付结果描述")
    private String message;

    @ApiModelProperty("支付日志ID")
    private Long paymentLogId;

    @ApiModelProperty("商户转账单号")
    private String outBizNo;

    @ApiModelProperty("支付宝转账单号")
    private String tradeNo;

    public static PaymentResultDTO success(Long paymentLogId, String outBizNo, String tradeNo) {
        PaymentResultDTO result = new PaymentResultDTO();
        result.setStatus(PaymentStatusEnum.SUCCESS.value());
        result.setMessage("支付成功");
        result.setPaymentLogId(paymentLogId);
        result.setOutBizNo(outBizNo);
        result.setTradeNo(tradeNo);
        return result;
    }

    public static PaymentResultDTO fail(String message) {
        PaymentResultDTO result = new PaymentResultDTO();
        result.setStatus(PaymentStatusEnum.FAIL.value());
        result.setMessage(message);
        return result;
    }

    public static PaymentResultDTO processing(Long paymentLogId, String outBizNo) {
        PaymentResultDTO result = new PaymentResultDTO();
        result.setStatus(PaymentStatusEnum.PROCESSING.value());
        result.setMessage("支付处理中");
        result.setPaymentLogId(paymentLogId);
        result.setOutBizNo(outBizNo);
        return result;
    }
}
